package com.piece.admin.model;

import com.piece.core.framework.annotation.translate.DicTranslate;
import com.piece.core.framework.support.model.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;

@Data
@Entity
@NoArgsConstructor
@Table(name = "tb_sys_role")
@ApiModel(value = "系统角色表: tb_sys_role")
public class TbSysRole extends BaseEntity implements Serializable {

    @Id
    @Column(name = "role_id", length = 11)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @ApiModelProperty(value = "主键")
    private Long roleId;

    @Column(name = "role_name", length = 30)
    @ApiModelProperty(value = "角色名称")
    private String roleName;

    @Column(name = "role_key", length = 100)
    @ApiModelProperty(value = "角色权限标识")
    private String roleKey;

    @Column(name = "role_sort", length = 4)
    @ApiModelProperty(value = "显示顺序")
    private String roleSort;

    @Column(name = "data_scope", length = 1)
    @ApiModelProperty(value = "数据范围", notes = "1：全部数据权限；2：所属部门据权限；3：自定数据权限")
    private String dataScope;

    @Transient
    @ApiModelProperty(value = "数据范围")
    @DicTranslate(source = "dataScope", dicType = "sys_data_scope")
    private String dataScopeName;

    @Transient
    @ApiModelProperty(value = "部门范围")
    @DicTranslate(source = "roleId", proxy = "tbSysDeptService.findDeptIdByRole")
    private String scopeDeptId;

    @Column(name = "status", length = 1)
    @ApiModelProperty(value = "状态", notes = "0=正常,1=删除,2=停用")
    private String status;

    @Transient
    @ApiModelProperty(value = "状态名称")
    @DicTranslate(source = "status", dicType = "sys_normal_disable")
    private String statusName;

    @Column(name = "remark", length = 500)
    @ApiModelProperty(value = "备注")
    private String remark;

    @Transient
    @ApiModelProperty(value = "否存在此角色标识")
    private boolean flag = false;

    @Transient
    @ApiModelProperty(value = "菜单组")
    @DicTranslate(source = "roleId", proxy = "tbSysMenuService.findMenuIdByRole")
    private String menuIds;

    @Transient
    @ApiModelProperty(value = "菜单组名称")
    private String menuNames;

    @Transient
    @ApiModelProperty(value = "部门组")
    private String deptIds;

    @Transient
    @ApiModelProperty(value = "部门组名称")
    private String deptNames;

    @Transient
    @ApiModelProperty(value = "用户组")
    private String userIds;

    @Transient
    @ApiModelProperty(value = "用户组名称")
    private String userNames;
}
